function [mask] = GetTrainingMask(rgb)
%GETTRAININGMASK Summary of this function goes here
%   Detailed explanation goes here

I = rgb;

imR = I(:,:,1);
imG = I(:,:,2);
imB = I(:,:,3);

imBinaryR = im2bw(imR, graythresh(imR));
imBinaryG = im2bw(imG, graythresh(imG));
imBinaryB = im2bw(imB, graythresh(imB));

% Need segmented objects to be white and background to be black
% imBinary = imcomplement(imBinaryR&imBinaryG&imBinaryB);
imBinary = imBinaryR&imBinaryG&imBinaryB;

se = strel('disk',5);
imClean = imclose(imBinary,se);

imClean = imfill(~imClean,'holes');
%imClean = imclearborder(imClean);

mask = imClean;

end

